﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Duoease.ContainerModel.Utils
{
    public class ModelUtil
    {
        public static string GetLetter(int num)
        {
            switch (num)
            {
                case 1:
                    return "A";
                case 2:
                    return "B";
                case 3:
                    return "C";
                case 4:
                    return "D";
                case 5:
                    return "E";
                case 6:
                    return "F";
                case 7:
                    return "G";
                case 8:
                    return "H";
                case 9:
                    return "I";
                case 10:
                    return "J";
                case 11:
                    return "K";
                case 12:
                    return "L";
                case 13:
                    return "M";
                default:
                    return "";
            }
        }
        public static int GetCodeValue(string ch)
        {
            int i;
            try
            {
                i = int.Parse(ch);
            }
            catch {
                i = (int)char.Parse(ch) - 55;
            }
           
            return i;
        }

        public static string GetCodeNo(int num)
        {
            if (num < 10)
            {
                return num.ToString();
            }
            switch (num)
            {               
                case 10:
                    return "A";
                case 11:
                    return "B";
                case 12:
                    return "C";
                case 13:
                    return "D";
                case 14:
                    return "E";
                case 15:
                    return "F";
                case 16:
                    return "G";
                case 17:
                    return "H";
                case 18:
                    return "I";
                case 19:
                    return "J";
                case 20:
                    return "K";
                case 21:
                    return "L";
                case 22:
                    return "M";
                default:
                    return "";
            }
        }

        public static int GetNumber(string ch)
        {
            
            switch (ch)
            {
                case "A":
                    return 1;
                case "B":
                    return 2;
                case "C":
                    return 3;
                case "D":
                    return 4;
                case "E":
                    return 5;
                case "F":
                    return 6;
                case "G":
                    return 7;
                case "H":
                    return 8;
                case "I":
                    return 9;
                case "J":
                    return 10;
                case "K":
                    return 11;
                case "L":
                    return 12;
                case "M":
                    return 13;
            }
            return 0;
        }
    }
}
